﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Homework3输出质数
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime startTime = DateTime.Now;
            //Console.Write(2 + " ");
            int j = 0, k = 1;
            for (int Number = 3; Number < 100000; Number++)
            {
                double num = System.Math.Sqrt(Number);
                for (int i = 2; i <= num; i++)
                {
                    if (Number % i == 0)
                    {
                        j = j + 1;
                        break;
                    }
                }
                if (j == 0)
                {
                    k = k + 1;
                  /*  if (k % 15 == 0)
                    {
                        Console.WriteLine(Number);
                    }
                    else
                    {
                        Console.Write(Number + " ");
                    }*/
                }
                j = 0;
            }
            DateTime endTime = DateTime.Now;
            Console.WriteLine();
            Console.WriteLine($"100000内共{k}个质数");
            Console.WriteLine($"共耗时{endTime - startTime}");
            Console.ReadKey();
        }
    }
}
